package com.powernode.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.powernode.domain.Member;
import com.powernode.mapper.MemberMapper;
import com.powernode.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> implements MemberService{

    @Autowired
    private MemberMapper memberMapper;

    @Override
    public boolean updateById(Member member) {
        member.setUpdateTime(new Date());
        return super.updateById(member);
    }

    @Override
    public List<Member> queryMemberListByOpenIds(List<String> openIds) {
        return memberMapper.selectList(new LambdaQueryWrapper<Member>()
                .in(Member::getOpenId,openIds)
        );
    }

    @Override
    public Member queryMemberByOpenId(String openId) {
        return memberMapper.selectOne(new LambdaQueryWrapper<Member>().eq(Member::getOpenId, openId));
    }
}
